package top.huxy.web.core;

public interface ReturnResultAble {
    default <T> Result<T> clientError(T data) {
        return new Result<>(400, "error", data);
    }

    default <T> Result<T> clientError(T data, String msg) {
        return new Result<>(400, msg, data);
    }

    default <T> Result<T> success(T data) {
        return new Result<>(200, "ok", data);
    }

    default <T> Result<T> success(T data, String msg) {
        return new Result<>(200, msg, data);
    }

    default <T> Result<T> notFound(T data) {
        return new Result<>(404, "not found", data);
    }

    default <T> Result<T> notFound(T data, String msg) {
        return new Result<>(404, msg, data);
    }

    default <T> Result<T> serverError(T data) {
        return new Result<>(500, "server error", data);
    }

    default <T> Result<T> serverError(T data, String msg) {
        return new Result<>(500, msg, data);
    }
}
